<template>
  <div>
    <h1>通知公告</h1>
    <van-button @click="ss">新增</van-button>
    <div v-show="is_show">
      <van-button @click="ss11">取消</van-button>

      <van-row>
      <van-col span="10" offset="2"> 标题: <van-field label="请输入标题" v-model="form.title"/></van-col>
      <van-col span="10" offset="2"> 消息类型:
        <select v-model="form.notice_type">
        <option value="1">通知公告</option>
        <option value="2">系统消息</option>
      </select></van-col>
    </van-row>
    <van-row>
      <van-col span="10" offset="2"><div class="block">
        <span class="demonstration">开始时间: </span>
        <el-date-picker
            v-model="form.ctime"
            type="datetime"
            placeholder="请输入开始时间"
            range-separator="To"
            value-format='YYYY-MM-DD HH:mm:ss'
        >
        </el-date-picker>
      </div></van-col>

    </van-row>
    <van-row>
      <van-col span="10" offset="2"> 优先级:
        <select v-model="form.level">
        <option value="1">高级</option>
        <option value="2">中级</option>
        <option value="3">低级</option>
      </select>
      </van-col>
      <van-col span="10" offset="2"> 通告类型:
        <select @change="changetype" v-model="form.type">
        <option value="1">全体用户</option>
        <option value="2">指定部门</option>
        <option value="3">指定用户</option>
      </select>
        <el-dialog v-model="dialogTableVisible">
          <el-tree
              :data="data"
              show-checkbox
              node-key="id"
              :props="defaultProps"
              @check-change='getids'
          />
        </el-dialog>
      </van-col>
    </van-row>
      <van-row>
        <van-col span="10" offset="2" v-model="form.content">
          内容: <editor v-model="form.content"></editor>
        </van-col>
      </van-row>
      <van-button @click="addnx">提交</van-button>

    </div>

  </div>
</template>

<script>
import TEditor from "@/components/TEditor";
// import Deptree from "@/components/qian/deptree";
import myaxios from "@/http/axios";
export default {
  components:{
    // Deptree,
    'editor':TEditor
  },
  name: "nx_news",
  data() {
    return {
      data1: '',
      value1:[],
      value2:[],
      is_show:false,
      form:{},
      checkdvalues:[],
      dialogTableVisible:false,
      defaultProps: {
        children: 'children',
        label: 'name',
      },
      data:[]
    }
  },
  methods: {
    ss(){
      this.is_show = true
    },
    ss11(){
      this.is_show = false
    },
    changetype(){
      if (this.form.type==2 || this.form.type==3){
        this.getaudit()
        this.dialogTableVisible = true
      }
    },
    getaudit(){
      //读取公司部门角色列表
      myaxios('getcomanyuser','get').then(res=>{
        this.data = res.list
      })
      this.dialogTableVisible=true
    },
    getids(data){
      // let list=[]
      if (data.type==3){
        this.checkdvalues.push(data.id)
      }
      console.log(this.list)
    },
    addnx(){
      this.form.values = this.checkdvalues
      myaxios('noticem','post',this.form).then(res=>{
        alert(res.msg)
      })
    }
  },

  mounted() {
    // this.getaudit()
  }
}
</script>

<style scoped>

</style>